using UnityEngine;

namespace NodeCanvas.Variables
{
	[AddComponentMenu("")]
	public class GameObjectData : VariableData
	{
		public GameObject value;

		public override object objectValue
		{
			get
			{
				return value;
			}
			set
			{
				this.value = (GameObject)value;
			}
		}

		public override object GetSerialized()
		{
			GameObject gameObject = value;
			if (gameObject == null)
			{
				return null;
			}
			string text = "/" + gameObject.name;
			while (gameObject.transform.parent != null)
			{
				gameObject = gameObject.transform.parent.gameObject;
				text = "/" + gameObject.name + text;
			}
			return text;
		}

		public override void SetSerialized(object obj)
		{
			value = GameObject.Find(obj as string);
			if (value == null && !string.IsNullOrEmpty((string)obj))
			{
				Debug.LogWarning("GameObjectData Failed to load. GameObject is not in scene. Path '" + (obj as string) + "'");
			}
		}
	}
}
